const router = require('koa-router')();
// import {getUserList, register, removeUser} from '../app/controller/user'

const dao = require('./mockdao');

const RespEncode = require('../util/RespEncode')

const { toJson, getUserList } = dao;


router.get('/', function (ctx, next) {
    ctx.body = 'this a users response!';
});

router.get('/getuser2', function (ctx, next) {
    ctx.body = 'this a users response!22';
});

router.get('/getuser', async (ctx, next) => {
    
    try {
        var result = await getUserList();
        ctx.body = toJson(RespEncode.succData(result));
    } catch (e) {
        ctx.body = e;
    }

});
// router.post('/register', async (ctx, next) => {
//   console.log(ctx.request.body);
//   let reqBody = ctx.request.body;
//   ctx.body = await register(reqBody);
// });
// router.del('/removeUser', async (ctx, next) => {
//   console.log(ctx.request.body);
//   let reqBody = ctx.request.body;
//   ctx.body = await removeUser(reqBody);
// });


module.exports = router;